package com.petRescueCenter.demo.user.entity;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import com.petRescueCenter.demo.common.enumPackage.LockedEmun;
import com.petRescueCenter.demo.common.enumPackage.SexEmun;
import com.petRescueCenter.demo.common.enumPackage.TypeEmun;
import com.petRescueCenter.demo.pet.entity.Pet;
import com.petRescueCenter.demo.posting.entity.Posting;

@Entity
@Table(name = "t_user")
public class User {
	private Long id;
	private String password;
	private String name;
	private SexEmun sex;
	private String img;
	private TypeEmun type;
	private Set<Pet> adopts;
	// 发布的帖子
	private Set<Posting> postings;
	// 关注的帖子
	private Set<Posting> attentions;
	private String introduce;
	private LockedEmun Locked;
	private String tel;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	@Column(length = 255, nullable = false)
	public String getPassword() {
		return password;
	}

	public String getTel() {
		return tel;
	}

	public void setTel(String tel) {
		this.tel = tel;
	}

	@Column(length = 20, nullable = false)
	public String getName() {
		return name;
	}

	@Enumerated
	public SexEmun getSex() {
		return sex;
	}

	public String getImg() {
		return img;
	}

	@Column(nullable = false)
	public TypeEmun getType() {
		return type;
	}

	public LockedEmun getLocked() {
		return Locked;
	}

	@OneToMany
	@JoinColumn(name = "ownerId")
	public Set<Pet> getAdopts() {
		return adopts;
	}

	@OneToMany
	@JoinColumn(name = "userId")
	public Set<Posting> getPostings() {
		return postings;
	}

	@ManyToMany
	@JoinTable(name = "t_attention", joinColumns = { @JoinColumn(name = "userId") }, inverseJoinColumns = {
			@JoinColumn(name = "postingId") })
	public Set<Posting> getAttentions() {
		return attentions;
	}

	public String getIntroduce() {
		return introduce;
	}

	public void setAdopts(Set<Pet> adopts) {
		this.adopts = adopts;
	}

	public void setPostings(Set<Posting> postings) {
		this.postings = postings;
	}

	public void setAttentions(Set<Posting> attentions) {
		this.attentions = attentions;
	}

	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setSex(SexEmun sex) {
		this.sex = sex;
	}

	public void setImg(String img) {
		this.img = img;
	}

	public void setType(TypeEmun type) {
		this.type = type;
	}

	public void setLocked(LockedEmun locked) {
		Locked = locked;
	}

	@Override
	public String toString() {
		return "User [Id=" + id + ", password=" + password + ", name=" + name + ", sex=" + sex + ", img=" + img
				+ ", type=" + type + ", adopts=" + adopts + ", postings=" + postings + ", attentions=" + attentions
				+ ", introduce=" + introduce + ", Locked=" + Locked + "]";
	}

}
